package com.habitracker.controller;

import com.habitracker.model.Habit;
import com.habitracker.model.Goal;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;

public class DataManager {
    private List<Habit> habits;
    private List<Goal> goals;

    public DataManager() {
        initializeSampleData();
    }

    private void initializeSampleData() {
        habits = new ArrayList<>();
        habits.add(new Habit("习惯1"));
        habits.add(new Habit("习惯2"));
        habits.add(new Habit("习惯3"));

        goals = new ArrayList<>(Arrays.asList(
                new Goal("目标1", "学习", 0.0),
                new Goal("目标1", "日常", 0.0),
                new Goal("请输入", "运动", 0.0)
        ));
    }

    public List<Habit> getHabits() { return habits; }
    public void addHabit(Habit habit) { habits.add(habit); }

    public List<Goal> getGoalsByCategory(String category) {
        return goals.stream()
                .filter(goal -> goal.getCategory().equals(category))
                .toList();
    }

    public List<String> getGoalCategories() {
        return Arrays.asList("学习", "日常", "运动");
    }

    // 添加新目标的方法
    public void addGoal(Goal goal) {
        goals.add(goal);
    }
}